﻿using System;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    public class myAction
    {
        public int[] distinct(int[] inputArray)
        {
            // count is counter of repeatings
            int globalCount = 0;
            for (int i = 0; i < inputArray.Length - 1; i++)
            {
                for (int k = i + 1, count = 0; k < inputArray.Length - 1 && k + globalCount < inputArray.Length - 1; k++)
                {
                    if (inputArray[i] == inputArray[k])
                    {
                        globalCount++;
                        count++;
                        // more then one time meets the inputArray[i] item  
                    }
                    if (count > 0)
                        for (int j = k; j < inputArray.Length - count; j++)
                        {
                            inputArray[j] = inputArray[j + count];
                        }
                    count = 0;
                }
            }
            int[] outputArray = new int[inputArray.Length - globalCount - 1];
            for (int i = 0; i <= globalCount; i++)
                outputArray[i] = inputArray[i];
            return outputArray;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            int[] myArray = { 2, 4, 2, 8, 5, 2, 8, 10, 3, 2, 8, 10 };
            Console.Write("Source arrow: \t");
            for (int i = 0; i <= myArray.Length - 1; i++)
            {
                Console.Write("{0} ", myArray[i]);
            }
            Console.WriteLine("");
            myAction tool = new myAction();
            myArray = tool.distinct(myArray);
            Console.Write("Distinct arrow:\t");
            for (int i = 0; i <= myArray.Length - 1; i++)
            {
                Console.Write("{0} ", myArray[i]);
            }
            Console.ReadKey();
        }
    }
}
